//
//  ShangjiaTableViewCell.m
//  CarTown
//
//  Created by xionghao on 15/8/4.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "ShangjiaTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation ShangjiaTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.icon.layer.cornerRadius=self.icon.width/2;
    self.icon.layer.masksToBounds=YES;
}
-(void)setMode:(ShangpuMode *)mode{
    _mode=mode;
    self.name.text=_mode.title;
    
    if (_mode.power!=1&&_mode.power!=5&&_mode.power!=8) {
        self.haschecked.text=@"去认证,查看详情";
        self.typepic.hidden=YES;
        self.typelable.hidden=YES;
    }else{
        self.typepic.hidden=NO;
        self.typelable.hidden=NO;
    self.haschecked.text=_mode.phonenumber;
    }
    NSString *imgurl=[NSString getImageURLstr:_mode.logo];
    [self.icon sd_setImageWithURL:[NSURL URLWithString:imgurl] placeholderImage:[UIImage imageNamed:@"placehoder"]];
    
    if (_mode.sale_type) {
        
        self.typelable.text=_mode.sale_type;
        
        if ([_mode.sale_type isEqualToString:@"个人商铺"]) {
             self.typepic.image=[UIImage imageNamed:@"ico_p"];
        }else if ([_mode.sale_type isEqualToString:@"港口批发商"]){
            self.typepic.image=[UIImage imageNamed:@"ico_hk"];
        }else if ([_mode.sale_type isEqualToString:@"4S店"])
        {
             self.typepic.image=[UIImage imageNamed:@"ico_4s"];
        }
        else if ([_mode.sale_type isEqualToString:@"综合销售店"])
        {
            self.typepic.image=[UIImage imageNamed:@"ico_zonghe"];
        }else if ([_mode.sale_type isEqualToString:@"资源公司"]){
             self.typepic.image=[UIImage imageNamed:@"ico_z"];
        }
    }
    if (_mode.shop_type)
    {
    
    switch ([_mode.shop_type integerValue]) {
        case GANGKOU:
            self.typelable.text=@"港口批发商";
            self.typepic.image=[UIImage imageNamed:@"ico_hk"];
            break;
        case FOURS:
             self.typelable.text=@"4S店";
            self.typepic.image=[UIImage imageNamed:@"ico_4s"];
            break;
        case PERSONAL:
             self.typelable.text=@"个人商铺";
            self.typepic.image=[UIImage imageNamed:@"ico_p"];
            
            break;
        case ZIYUAN:
             self.typelable.text=@"资源公司";
            self.typepic.image=[UIImage imageNamed:@"ico_z"];
            break;
        case ZONGHE:
             self.typelable.text=@"综合销售店";
            self.typepic.image=[UIImage imageNamed:@"ico_zonghe"];
            break;
        default:
            break;
    }
    }
    
}
+(instancetype)cellWithTableView:(UITableView *)tableview{
    static NSString *CellID=@"SHJIA";
    
    ShangjiaTableViewCell *cell=[tableview dequeueReusableCellWithIdentifier:CellID];
    if (cell==nil) {
        [tableview registerNib:[UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil]forCellReuseIdentifier:CellID];
        cell=[tableview dequeueReusableCellWithIdentifier:CellID];

    }
    
    return cell;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
